﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxClasses;
using DoAn.DTO;

namespace DoAn.BAN
{
    public partial class BanTrang3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                speGiaMuaNgay.Enabled = false;
                //if (!IsPostBack)
                //{
                //    if (Session["SanPham"] != null)
                //    {
                //        SanDauGiaDTO san = new SanDauGiaDTO();
                //        san = (SanDauGiaDTO)Session["SanPham"];
                //        Response.Write("<script>alert('" + san.MaDanhMuc.ToString() + "')</script>");
                //    }
                //}

            }
        }
         

        protected void ckbMuaNgay_CheckedChanged(object sender, EventArgs e)
        {
            if (ckbMuaNgay.CheckState == CheckState.Checked)
            {
                speGiaMuaNgay.Enabled = true;
            }
            else
            {
                speGiaMuaNgay.Enabled = false;
            }
        }

        protected void bntNext_Click(object sender, EventArgs e)
        {
            SanDauGiaDTO san = new SanDauGiaDTO();
            san = (SanDauGiaDTO)HttpContext.Current.Session["SanPham"];
            if (ckbMuaNgay.CheckState == CheckState.Checked)
            {
                san.MuaNgay = true;
                san.GiaMuaNgay = float.Parse(speGiaMuaNgay.Value.ToString());
            }
            else
            {
                san.MuaNgay = false;
            }           
            san.GiaKhoiDiem = float.Parse(speGiaKhoiDiem.Value.ToString());
            san.NgayDangSP = DateTime.Now.Date;
            san.NgayKetThucDang = san.NgayDangSP.AddDays(int.Parse(speThoiGianDauGia.Value.ToString()));
            san.NgayKetThucSan = san.NgayDangSP.AddDays(int.Parse(speThoiGianDauGia.Value.ToString()));            
            Session["SanPham"] = san;
            Session["ThoiGianDauGia"] = speThoiGianDauGia.Value.ToString();
            Response.Redirect("~/BAN/BanTrang4.aspx");
        }
    }
}